package com.tradeplus.admin.dao;

import com.tradeplus.admin.model.Library;
import java.util.List;
import org.springframework.orm.hibernate3.HibernateTemplate;

public class LibraryDaoImpl implements LibraryDao {
    
    private HibernateTemplate hibernateTemplate;

    public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
        this.hibernateTemplate = hibernateTemplate;
    }

    @Override
    public void deleteLibrary(Long libraryId) {
        hibernateTemplate.delete(hibernateTemplate.get(Library.class, libraryId));
    }

    @Override
    public List<Library> loadLibrary() {
        return hibernateTemplate.find("from Library");
    }

    @Override
    public Library loadLibraryById(Long libraryId) {
        return (Library) hibernateTemplate.get(Library.class, libraryId);
    }

    @Override
    public void saveLibrary(Library library) {
        hibernateTemplate.merge(library);
    }
    
    
}
